home *** CD-ROM | disk | FTP | other *** search
/ Isometric Game Programming with DirectX 7.0 / Isometric Game Programming.iso / directx / dxf / samples / multimedia / directinput / diconfig / cdiacpage.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  6.1 KB  |  195 lines

  1. //-----------------------------------------------------------------------------
  2. // File: cdiacpage.h
  3. //
  4. // Desc: CDIDeviceActionConfigPage implements the page object used by the UI.
  5. //       A page covers the entire UI minus the device tabs and the bottons at
  6. //       the bottom.  The information window, player combo-box, genre combo-
  7. //       box, action list tree, and device view window are all managed by
  8. //       the page.
  9. //
  10. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  11. //-----------------------------------------------------------------------------
  12.  
  13. #ifdef FORWARD_DECLS
  14.  
  15.  
  16.     class CDIDeviceActionConfigPage;
  17.  
  18.  
  19. #else // FORWARD_DECLS
  20.  
  21. #ifndef __CDIACPAGE_H__
  22. #define __CDIACPAGE_H__
  23.  
  24. // For WINMM.DLL
  25. typedef MMRESULT (WINAPI * FUNCTYPE_timeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
  26. extern HINSTANCE g_hWinMmDLL;
  27. extern FUNCTYPE_timeSetEvent g_fptimeSetEvent;
  28.  
  29. //implementation class
  30. class CDIDeviceActionConfigPage : public IDIDeviceActionConfigPage, public CDeviceUINotify, public CFlexWnd
  31. {
  32. public:
  33.  
  34.     //IUnknown fns
  35.     STDMETHOD (QueryInterface) (REFIID iid, LPVOID *ppv);
  36.     STDMETHOD_(ULONG, AddRef) ();
  37.     STDMETHOD_(ULONG, Release) ();
  38.  
  39.     //IDirectInputActionConfigPage
  40.     STDMETHOD (Create) (DICFGPAGECREATESTRUCT *pcs);
  41.     STDMETHOD (Show) (LPDIACTIONFORMATW lpDiActFor);
  42.     STDMETHOD (Hide) ();
  43.  
  44.     // layout edit mode
  45.     STDMETHOD (SetEditLayout) (BOOL bEditLayout);
  46.  
  47.  
  48.     // Set the info box text
  49.     STDMETHOD (SetInfoText) (int iCode);
  50.  
  51.     // Unacquire and Reacquire the device for page's purposes
  52.     // (the configwnd needs to do this around SetActionMap() calls)
  53.     STDMETHOD (Unacquire) ();
  54.     STDMETHOD (Reacquire) ();
  55.  
  56. //    STDMETHOD (UnassignControlAtOffset) (DWORD dwOffset);
  57.  
  58.     //construction/destruction
  59.     CDIDeviceActionConfigPage();
  60.     ~CDIDeviceActionConfigPage();
  61.  
  62.  
  63.     // dialog window message handlers
  64. /*    BOOL OnInitDialog(HWND hWnd, HWND hwndFocus);
  65.     BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  66.     LRESULT OnNotify(WPARAM wParam, LPARAM lParam);
  67.     void OnPaint(HDC hDC);
  68.     void OnClick(POINT point, WPARAM, BOOL bLeft);*/
  69.  
  70. protected:
  71.     virtual void OnInit();
  72.     virtual void OnPaint(HDC hDC);
  73.     virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  74.     virtual void OnMouseOver(POINT point, WPARAM fwKeys);
  75.     virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  76.  
  77. private:
  78.     enum CONFIGSTATE {CFGSTATE_NORMAL, CFGSTATE_ASSIGN};
  79.  
  80. //    HWND m_hWnd; // handle to the page dialog window
  81.     LONG m_cRef; //reference count
  82.     LPDIACTIONFORMATW m_lpDiac;
  83.     DIDEVICEINSTANCEW m_didi;
  84.     LPDIRECTINPUTDEVICE8W m_lpDID;
  85.     CUIGlobals *m_puig;
  86.     IDIConfigUIFrameWindow *m_pUIFrame;
  87.     CONFIGSTATE m_State;
  88.  
  89.     // device ui
  90.     CDeviceUI *m_pDeviceUI;
  91.     CDeviceControl *m_pCurControl;
  92.     virtual void DeviceUINotify(const DEVICEUINOTIFY &);
  93.     virtual BOOL IsControlMapped(CDeviceControl *);
  94.  
  95.     // ui logic
  96.     void SetCurrentControl(CDeviceControl *pControl);
  97.     void NullAction(LPDIACTIONW lpac);
  98.     void UnassignControl(CDeviceControl *pControl);
  99.     friend void CallUnassignControl(CDeviceControl *pControl, LPVOID pVoid, BOOL bFixed);
  100.     void UnassignAction(LPDIACTIONW lpac);
  101.     void UnassignSpecificAction(LPDIACTIONW lpac);
  102.     void UnassignActionsAssignedTo(const GUID &guidInstance, DWORD dwOffset);
  103.     void AssignCurrentControlToAction(LPDIACTIONW lpac);
  104.     void ActionClick(LPDIACTIONW lpac);
  105.     void EnterAssignState();
  106.     void ExitAssignState();
  107.     void UnassignCallout();
  108.     void SetAppropriateDefaultText();
  109.  
  110.     void GlobalUnassignControlAt(const GUID &, DWORD);
  111.     void SetControlAssignments();
  112.  
  113.     void ShowCurrentControlAssignment();
  114.  
  115.     CBitmap *m_pbmRelAxesGlyph;
  116.     CBitmap *m_pbmAbsAxesGlyph;
  117.     CBitmap *m_pbmButtonGlyph;
  118.     CBitmap *m_pbmHatGlyph;
  119.     CBitmap *m_pbmCheckGlyph;
  120.     CBitmap *m_pbmCheckGlyphDark;
  121.     CBitmap *m_pbmIB;
  122.     CBitmap *m_pbmIB2;
  123.     void InitResources();
  124.     void FreeResources();
  125.  
  126.     RECT m_rectIB;
  127.     RECT m_rectIBLeft;
  128.     RECT m_rectIBRight;
  129.     LPTSTR m_tszIBText;
  130.     POINT m_ptIBOffset;
  131.     POINT m_ptIBOffset2;
  132.     RECT m_rectIBText;
  133.     void InitIB();
  134.  
  135.     CViewSelWnd m_ViewSelWnd;
  136.     void DoViewSel();
  137.  
  138.     CFlexTree m_Tree;
  139.     CFTItem *m_pRelAxesParent, *m_pAbsAxesParent, *m_pButtonParent, *m_pHatParent, *m_pUnknownParent;
  140.     void ClearTree();
  141.     void InitTree(BOOL bForceInit = FALSE);
  142.     DWORD m_dwLastControlType;
  143.  
  144.     CFTItem *GetItemForActionAssignedToControl(CDeviceControl *pControl);
  145.     int GetNumItemLpacs(CFTItem *pItem);
  146.     LPDIACTIONW GetItemLpac(CFTItem *pItem, int i = 0);
  147.     typedef CArray<LPDIACTIONW, LPDIACTIONW &> RGLPDIACW;
  148.     // GetItemWithActionNameAndSemType returns an item with the specified action name and semantic type.  NULL if none.
  149.     CFTItem *GetItemWithActionNameAndSemType(LPCWSTR acname, DWORD dwSemantic);
  150.     BOOL IsActionAssignedHere(int index);
  151.  
  152.     // quick fix for offset->objid change:
  153.     void SetInvalid(LPDIACTIONW);
  154.     DWORD GetOffset(LPDIACTIONW);
  155.     void SetOffset(LPDIACTIONW, DWORD);
  156.     bidirlookup<DWORD, DWORD> offset_objid;
  157.     HRESULT InitLookup();
  158.  
  159.     // dropdowns
  160.     CFlexComboBox m_UserNames, m_Genres;
  161.  
  162.     // Information window
  163.     CFlexInfoBox m_InfoBox;
  164.  
  165.     // Sort Assigned check box for keyboard devices
  166.     CFlexCheckBox m_CheckBox;
  167.  
  168.     // device control
  169.     DWORD m_cbDeviceDataSize;
  170.     DWORD *m_pDeviceData[2];
  171.     int m_nOnDeviceData;
  172.     BOOL m_bFirstDeviceData;
  173.     void InitDevice();
  174.     void DeviceTimer();
  175.     static void CALLBACK DeviceTimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
  176.     void DeviceDelta(DWORD *pData, DWORD *pOldData);
  177.     void AxisDelta(const DIDEVICEOBJECTINSTANCEW &doi, BOOL data, BOOL old);
  178.     void ButtonDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  179.     void PovDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  180.     void ActivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  181.     void DeactivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  182.     bidirlookup<DWORD, int> objid_avai;
  183.     typedef CArray<int, int &> AxisValueArray;
  184.     CArray<AxisValueArray, AxisValueArray &> m_AxisValueArray;
  185.     void StoreAxisDeltaAndCalcSignificance(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD olddata, BOOL &bSig, BOOL &bOldSig);
  186.  
  187.     // page index
  188.     int m_nPageIndex;
  189. };
  190.  
  191.  
  192. #endif //__CDIACPAGE_H__
  193.  
  194. #endif // FORWARD_DECLS
  195.